package com.hyt.it.ogt.ykcj.service.zs;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.ykcj.domain.exam.ExamResultDataDownLoadRecord;
import com.hyt.it.ogt.ykcj.domain.grade.EnterpriseExamineeCertificateRelation;
import com.hyt.it.ogt.ykcj.domain.param.CertificatePageParam;
import com.hyt.it.ogt.ykcj.domain.zs.ZsExamineeInfo;
import com.hyt.it.ogt.ykcj.domain.zs.ZsInfo;
import com.hyt.it.ogt.ykcj.domain.zs.dto.ZsExamineeInfoExportZip;
import com.hyt.it.ogt.ykcj.domain.zs.dto.ZsInfoDTO;
import com.hyt.it.ogt.ykcj.domain.zs.vo.ImportCertificateExamineesMessageVO;
import com.hyt.it.ogt.ykcj.domain.zs.vo.ZsExamInfoVO;
import com.hyt.it.ogt.ykcj.domain.zs.vo.ZsExamScoreLineVO;
import com.hyt.it.ogt.ykcj.domain.zs.vo.ZsInfoVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 证书信息接口
 *
 * @author admin
 * @date 2021-06-18
 */
public interface IZsInfoService extends IService<ZsInfo> {

    String ZIP_SUFFIX = "zip";

    String IMAGE_SUFFIX = ".jpg";

    String ID_NO_REGEX = "[A-Za-z0-9()]+";

    /**
     * 导出PDF证书到ZIP文件
     *
     * @param fileName
     * @param examineeInfoExportZips
     * @return
     */
    String exportCertificatePdfZip(String fileName, List<ZsExamineeInfoExportZip> examineeInfoExportZips);

    void createCertificate(ZsInfoDTO zsInfoDTO);

    void editCertificate(ZsInfoDTO zsInfoDTO);

    /**
     * 同步考生证书关系
     *
     * @param zsInfoDTO
     * @param examineeCertificateRelationSaveList
     */
    void synchronizeListExamineeCertificateRelation(ZsInfoDTO zsInfoDTO, List<EnterpriseExamineeCertificateRelation> examineeCertificateRelationSaveList);

    void deleteCertificate(String id, String deleteBy);

    /**
     * 证书名称是否存在
     *
     * @param zsName   证书名称
     * @param officeId 机构id
     * @return
     */
    Boolean checkZsNameExist(String zsId, String zsName, String officeId);

    ZsInfoVO queryCertificate(String id);

    IPage<ZsInfoVO> certificatePage(CertificatePageParam param);

    List<ZsExamScoreLineVO> getExamScoreLine(String examId);

    Boolean setCertificateStatus(String id, Integer status, String updateBy);

    ZsInfoVO examGetZsInfo(String examId);

    /**
     * 下载证书人员导入模板
     *
     * @param infoId 证书信息ID
     */
    void downloadExamineeImportTemplate(String infoId, HttpServletResponse response) throws IOException;

    /**
     * 下载导入证书编码模板
     *
     * @param infoId   证书信息ID
     * @param response
     */
    void downloadCertificateCodeTemplate(String infoId, HttpServletResponse response) throws IOException;

    void issueCertificate(String infoId, String consumerId);

    ImportCertificateExamineesMessageVO importCertificateExamineesCheck(MultipartFile file, String infoId) throws IOException;

    Boolean importCertificateExamineesData(List<Map<String, String>> certificateExaminees, String infoId);

    /**
     * 导入考生照片
     *
     * @param zipFileUrl
     * @param infoId
     * @throws IOException
     */
    void importCertificateExamineesPhoto(String zipFileUrl, String infoId) throws IOException;

    ImportCertificateExamineesMessageVO importCertificateSerialNumberCheck(MultipartFile file, String infoId) throws IOException;

    Long importCertificateSerialNumberData(List<Map<String, String>> certificateSerialNumbers, String infoId);

    String batchDownloadCertificate(String infoId, ExamResultDataDownLoadRecord projectDataDownLoadRecord, HttpServletResponse response) throws Exception;

    void exportCertificateExamineesExcel(String infoId, HttpServletResponse response);

    /***
     * 获取机构下关联证书的考试列表
     * @param officeId
     * @return
     */
    List<String> getExamsByOfficeId(String officeId, String zsId);

    /***
     * 获取机构下关联证书的考试列表
     * @param examId
     * @return
     */
    List<ZsInfo> listByExamId(String examId);

    ApiResponse<Object> checkZsData(ZsInfoDTO zsInfoDTO, Boolean isUpdate);

    String batchDownloadCertificateNoSignature(String infoId, ExamResultDataDownLoadRecord finalProjectDataDownLoadRecord, HttpServletResponse response);

    /**
     * 查询证书通过ID
     *
     * @param id
     * @return
     */
    ZsInfo selectCacheById(String id);

    /**
     * 导出带有电子签章的ZIP文件
     *
     * @param fileName
     * @param examineesInfos
     * @return
     */
    String exportCertificateHasSignaturePdfZip(String fileName, List<ZsExamineeInfo> examineesInfos);

    /**
     * 获取机构下所有考试信息列表
     *
     * @param deptIds
     * @return
     */
    List<ZsExamInfoVO> queryExamByOfficeId(Set<String> deptIds);

    /**
     * 获取数据来源为考试的证书
     *
     * @param examId
     * @return
     */
    ZsInfoVO getZsInfoByDataSourceToExam(String examId);

    /**
     * 获取数据来源为考试的证书
     *
     * @param examId
     * @return
     */
    List<ZsInfoVO> listZsInfoByDataSourceToExam(String examId);

    /**
     * 获取发布类型为考试的证书
     *
     * @param examId
     * @return
     */
    ZsInfoVO getZsInfoByPublishTypeToExam(String examId);
}
